package com.tourism.tourismGYM.controller;

import java.util.HashMap;
import java.util.List;
import java.util.Map;


import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.util.Assert;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.tourism.tourismGYM.entity.TourismApm;
import com.tourism.tourismGYM.service.TourismApmService;
/**
 * 活动项目控制类
 * @author gym
 *
 */
@RestController
@RequestMapping(value = "/tourism/apm")
public class TourismApmController {
	@Autowired
	private TourismApmService tourismApmService;
	 /**
     * 分页查询
     * @return
     */
    @RequestMapping(value="/page", method=RequestMethod.GET)
    public ResponseEntity<Page<HashMap>> page(@RequestParam Map<String, Object> condition){
		Page<HashMap> page = tourismApmService.page(condition);
        return new ResponseEntity<Page<HashMap>>(page,HttpStatus.OK);
    }
    /**
     * 添加
     * @param tourismApm
     * @return
     */
    @RequestMapping(value="/create",method= RequestMethod.POST)
    public TourismApm create(@RequestBody TourismApm tourismApm) {
        Assert.isTrue(tourismApm != null, "实体不能为空");
        return tourismApmService.create(tourismApm);
    }
    /**
     * 获取全部
     * @return
     */
    @RequestMapping(value="/getAll", method=RequestMethod.GET)
    public List<TourismApm> getAll(){
    	return tourismApmService.getAll();
    }
    /**
     * 根据id查询
     * @return
     */
    @RequestMapping(value="/{id}", method=RequestMethod.GET)
    public TourismApm getById(@PathVariable String id){
    	return tourismApmService.getById(id);
    }
    /**
     * 修改
     * @param gym
     * @return
     */
    @RequestMapping(value="/update/{id}",method=RequestMethod.PUT)
    public TourismApm update(@PathVariable String id , @RequestBody TourismApm tourismApm) {
        Assert.isTrue(null != id && !id.isEmpty(), "id不能为空");
        Assert.isTrue(tourismApm != null, "实体不能为空");
        tourismApm.setId(id);
        return tourismApmService.update(tourismApm);
    }
    /**
     * 删除
     * @param id
     * @return
     */
    @RequestMapping(value="/delete/{id}",method=RequestMethod.DELETE)
    public boolean delete(@PathVariable String id) {
        Assert.isTrue(null != id && !id.isEmpty(), "id不能为空");
        return tourismApmService.delete(id);
    }
}
